package com.niiwoo.civet.trade.enums.kaola;

import com.niiwoo.tripod.provider.exception.NoSuchEnumValueException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum TreatyRecordStatusEnum {

    REVIEW("0", "待复核"),
    EFFECT("1", "生效"),
    FAILURE("2", "失败"),
    FREEZE("3", "冻结"),
    FIRE("6", "解约");

    private String code;
    private String desc;

    public static TreatyRecordStatusEnum enumOf(String code) {
        return Arrays.stream(values())
                .filter(v -> v.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> new NoSuchEnumValueException(String.valueOf(code)));
    }

}
